from qcloud_cos import CosConfig
from qcloud_cos import CosS3Client
from django.conf import settings

import base

file_path = r"D:\code\Python_virtual_venvs\website1\tracer\app01\scripts\xigewen.png"
print("文件路径:", file_path)  # 检查输出是否有效


region = 'ap-chengdu'  # 替换为用户的 Region

config = CosConfig(Region=region, SecretId=settings.SECRET_ID, SecretKey=settings.SECRET_KEY)

client = CosS3Client(config)

response = client.upload_file(
    Bucket='sandox-1320997346',
    LocalFilePath=file_path,  # 本地文件的路径
    Key='p1.png'  # 上传到桶之后的文件名
)
print(response['ETag'])